class Solution(object):
    def twoSum(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: List[int]
        """
        # for i in range(len(nums)):
        #     for j in range(i+1, len(nums)):
        #         if (nums[i] + nums[j] == target):
        #             flag = [i, j]
        #             return flag
        list_nums = dict()
        for i in range(len(nums)):
            comptent = target - nums[i]
            if comptent in list_nums.keys():
                j = list_nums.get(comptent)
                return [j, i]

            list_nums[nums[i]] = i

if __name__ == '__main__':
    a = Solution()
    b = a.twoSum([3, 2, 4], 6)
    print(b)
